#include "stm32f10x.h"                  // Device header
#include "PWM.h"

//引脚定义
#define  AIN1  PA0
#define  AIN2  PA1
#define  BIN1  PA2
#define  BIN2  PA3

void Motor_Init(void)
{
	PWM_Init();	
}

/*两路PWM驱动一个电机，这两个PWM要配置为相反的属性（也就是电平要不一致，电机才会转动）*/
void Motor_SetLeftSpeed(int8_t Speed)
{
	if(Speed>=0)
	{
		PWM_SetCompare1(100);
		PWM_SetCompare2(100-Speed);
	}
	else
	{
		PWM_SetCompare1(100+Speed);
		PWM_SetCompare2(100);
	}
}

void Motor_SetRightSpeed(int8_t Speed)
{
	if(Speed>=0)
	{
		PWM_SetCompare3(100);
		PWM_SetCompare4(100-Speed);
	}
	else
	{
		PWM_SetCompare3(100+Speed);
		PWM_SetCompare4(100);
	}
}
